<template>
<transition name="el-zoom-in-center">
<div class="JNPF-preview-main">
    <div class="JNPF-common-page-header">
        <el-page-header @back="goBack"
                        content="规则配置"/>
        <div class="options">
            <el-button @click="goBack">取 消</el-button>
        </div>
    </div>
<el-row :gutter="15" class=" main" :style="{margin: '0 auto',width: '100%'}">
<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" >
    <template v-if="!loading">
	    <el-col :span="24" >
		<el-form-item  label-width="0">
		<groupTitle  content-position="center"  :closable= "false"  content ="单据转换详情配置" >
		</groupTitle>
	</el-form-item>
	</el-col>


    <el-table
       :data="tableData"
       header-row-class-name="header_row_className"
       :header-cell-style="{
       'background-color': '#E5EEFF'
       }"
     @selection-change="handleSelectionChange"
      style="width: 100%">
         <el-table-column
             type="selection"
             label="全选"
             align="center"
             v-if="state==0|| state==8|| state==1"
             width="80">
           </el-table-column>
         <el-table-column
         align="center"
         prop="wx_code"
         label="订单号"
         >
          <template slot-scope="scope">
            <div>
              <span class="redCircle"></span>
               <a class="tab_a" @click="toDetail(scope,'订单详情')">{{scope.row.wx_code}}</a>
               <span>(待打印)</span>
            </div>
          </template>
       </el-table-column>
       <el-table-column
           label="类型"
           align="center"
           >
           <template slot-scope="scope">
             <div>{{scope.row.takeaway=='0'?'到店订单':'外卖点餐'}}</div>
           </template>
       </el-table-column>
       <el-table-column
           prop="small_code"
           label="桌位号/取餐号"
           align="center"
           >
       </el-table-column>
       <el-table-column
         prop="shop_admin_phone"
         label="操作员"
         align="center"
         width="100">
       </el-table-column>
       <el-table-column
           prop="parent_payment"
           label="支付方式"
           align="center"
           >
           <template slot-scope="scope">
             <div class="green" v-if="scope.row.parent_payment==1001">现金支付</div>
             <div class="green" v-if="scope.row.parent_payment==1002">签单记账</div>
             <div class="green" v-if="scope.row.parent_payment==1003">线下刷卡</div>
             <div class="green" v-if="scope.row.parent_payment==1004">线上支付</div>
             <div class="green" v-if="scope.row.parent_payment==1005">龙支付</div>
            </template>
       </el-table-column>
       <el-table-column
           prop="pay_money"
           label="订单支付金额"
           align="center"
           >
       </el-table-column>
       <el-table-column
           prop="grand_total"
           label="总计(结算金额)"
           align="center"
           >
       </el-table-column>
       <el-table-column
           prop="refund_penging_fee"
           label="待退款金额"
           align="center"
           >
       </el-table-column>
       <el-table-column
           prop="refund_fee"
           label="已退款金额"
           align="center"
           >
       </el-table-column>
       <el-table-column
           prop="status"
           label="状态"
           align="center"
           >
           <template slot-scope="scope">
             <div>{{scope.row.closed=='0'?'未关闭':'已关闭'}}</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==0">(未付款)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==1">(已付款)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2">(配送中)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==5">(退款审核)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==6">(全额退款)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==7">(部分退款)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==8">(已下单)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==9">(已完成)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2101">配送中(待配送员接单)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2102">配送中(配送员已接单)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2103">配送中(配送员配送中)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2104">配送中(配送员配送完成)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2105">配送中(配送员取消配送)</div>
             <div class="green" v-if="scope.row.closed=='0' && scope.row.status==2106">配送中(配送员申请取消)</div>
            </template>
       </el-table-column>
       <el-table-column
           prop="create_date"
           label="下单时间"
           align="center"
           >
       </el-table-column>
       <el-table-column
         prop="operation"
         label="操作"
         align="center"
         width="180">
        <template slot-scope="scope">
        <div class="operationVid">
          <span class="operationBef" @click="payList(scope)" v-if="handleMenu_1(scope.row)=='付款'">付款</span>
          <span class="operationBef" @click="operFinish(scope)" v-if="handleMenu_1(scope.row)=='完成'">完成</span>
          <span class="operationBef" @click="operFinish(scope)" v-if="handleMenu_1(scope.row)=='审核'">审核</span>
          <el-dropdown trigger="click" @command="handleCommand">
               <span class="el-dropdown-link">
                 更多<i class="el-icon-arrow-down el-icon--right"></i>
               </span>
               <el-dropdown-menu slot="dropdown">
                   <el-dropdown-item :command="beforeHandleCommand(scope,'订单详情')" v-if="handleMenu_2(scope.row).has('订单详情')">订单详情</el-dropdown-item>
                   <el-dropdown-item :command="beforeHandleCommand(scope,'前台打印')" v-if="handleMenu_2(scope.row).has('前台打印')">前台打印</el-dropdown-item>
                   <el-dropdown-item :command="beforeHandleCommand(scope,'后厨打印')" v-if="handleMenu_2(scope.row).has('后厨打印')">后厨打印</el-dropdown-item>
                   <el-dropdown-item :command="beforeHandleCommand(scope,'订单退款')"  v-if="handleMenu_2(scope.row).has('订单退款')">订单退款</el-dropdown-item>
                   <el-dropdown-item :command="beforeHandleCommand(scope,'关闭订单')" v-if="handleMenu_2(scope.row).has('关闭订单')">关闭订单</el-dropdown-item>
                 </el-dropdown-menu>
           </el-dropdown>
       </div>
        </template>
       </el-table-column>
     </el-table>



    </template>
</el-form>
    </el-row>
    </div>
</transition>
</template>
<script>
    import request from '@/utils/request'
    import PrintBrowse from '@/components/PrintBrowse'
    import jnpf from '@/utils/jnpf'
    export default {
        components: {PrintBrowse},
        props: [],
        data() {
            return {
                visible: false,
                loading: false,
                printBrowseVisible: false,
                printId: '',
            dataForm: {
                id :'',
                            sourcetable : "",
                            sourcemark : '',
                            sourcetypecode : '',
                            targettable : "",
                            targetmark : '',
                            targettypecode : '',
                            description : '',
                            org : [],
                            creatoruserid : "",
                            creatortime : "",
                            lastmodifyuserid : "",
                            lastmodifytime : "",
                            id : '',
            },

        }
        },
        computed: {},
        watch: {},
        created() {

        },
        mounted() {},
        methods: {
              //处理表格多选
              handleSelectionChange(val) {
                this.multipleSelection = val;
                this.selectArray=this.multipleSelection.map((item)=>{
                  let id=item.id
                  return id
                })
              },
            dataInfo(dataAll){
                let _dataAll =dataAll
                this.dataForm = _dataAll
            },

                goBack() {
                    this.$emit('refresh')
                },
            init(id) {
                this.dataForm.id = id || 0;
                this.visible = true;
                this.$nextTick(() => {
                    if(this.dataForm.id){
                        this.loading = true
                        request({
                            url: '/api/example/SmBillchange/detail/'+this.dataForm.id,
                            method: 'get'
                        }).then(res => {
                            this.dataInfo(res.data)
                            this.loading = false
                        })
                    }

                })
            },
        },
    }

</script>
